//
//  UserGraphInterface.h
//  p4
//
//  Created by CaoJun on 15/5/21.
//  Copyright (c) 2015年 com.baidao. All rights reserved.
//

#ifndef __p4__UserGraphInterface__
#define __p4__UserGraphInterface__

#include "YTXTime.h"
#include "EnumDefinition.h"
#include "json.h"

#include <string>
#include <vector>

namespace ytx
{
    struct UGCPoint
    {
        YTXTime dataX;//KLineData用
        YTXTime preDataX;//KLineData用
        double dataY;
        int dataIndexX;//AVGData用
    };
    
    namespace UserGraphType{
        enum UserGraphType
        {
            UserGraphNone,
            UserGraphLine,
            UserGraphRectangle
        };
    }
    
    class UserGraph
    {
    public:
        UserGraphType::UserGraphType type;
        float lineWidth;
        std::string lineColor;
        UGCPoint p1;
        UGCPoint p2;
        std::string toJSONString();
        YTXJson::Value toJSONValue();
        UserGraph();
        UserGraph (YTXJson::Value josn);
        
    };
    
    
    class UserGraphInterface
    {
    protected:
        std::vector<UserGraph> userGraphs;
    public:
        LineType::LineType userGraphLineType;

        std::string userGraphId;

        UserGraphInterface(std::string userGraphId, LineType::LineType userGraphLineType);

        static std::string UserGraphDefaultKey;
        
        virtual void clearUserGraphByUserDefault();
        
        virtual void updateUserGraphToUserDefault(UserGraph userGraph);
        
        virtual void saveUserGraphToUserDefault();
        
        virtual void addUserGraphToUserDefault(UserGraph userGraph);
        
        virtual void loadUserGraphByUserDefault();
        
        virtual void cancelLastUserGraph();

        virtual std::string getUserDefaultKey();
        
        const std::vector<UserGraph> getUserGraphs();
        
        void setUserGraphs(std::vector<UserGraph> userGraph); // not Save
        
        virtual UGCPoint getUserGraphWithPoint(float x1, float y1);
    };
}

#endif /* defined(__p4__UserGraphInterface__) */
